<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
/*******basic*******/
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(!$postdata['ordersn']){
			exi('请输入订单号！','error');
		}
		if(!$postdata['aliapp_id']){
			exi('请选择上链支付宝小程序！','error');
		}
		$bizContent=$this->model('member')->orderinfo($postdata['ordersn'],$postdata['aliapp_id']);
		$hash=$this->model('model')->biznotary($bizContent['hash']);
		$bizContent['leaseServiceFileHash']=$hash;
		$res=$this->model('model')->upinfo($bizContent,'','',true);
		$order=pdo_get('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ordersn'=>$postdata['ordersn']));
		$api_data=json_decode($order['api_data'],true);
		$api_data['liandata']=$res;
		$api_data['leaseServiceFileHash']=$hash;
		pdo_update('jy_weishop_order',array('api_data'=>ijson_encode($api_data)),array('id'=>$order['id']));
		$bizContent=$this->model('member')->ordergoodsinfo($order['id'],$postdata['aliapp_id']);
		$res=$this->model('model')->upinfo($bizContent,'orderProduct','',true);
		exi('上链成功！');
	}
	$return['item']=$this->plugin_setting('basic');
	$htmls=array(
		'type'=>'edit',
		'desc'=>'订单上链接口测试',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'订单上链接口测试',
				'list'=>array(
					array('type'=>'tip','title'=>'<red>PHP必须7.2以上</red>
					</br>蚂蚁链租赁平台：https://antchain.antgroup.com/docs/11/190768
					</br>API文档：https://apdevcenter.antchain.antgroup.com/developer/product/BOT?api=blockchain.bot.lease.risk.query_1.0
					</br>产品文档：https://antchain.antgroup.com/products
					'),
					array('type'=>'select','title'=>'选择上链支付宝小程序','name'=>'aliapp_id','options'=>'apps','help'=>'目前主要是支付宝小程序要上链'),
					array('type'=>'string','title'=>'输入订单号','name'=>'ordersn','help'=>''),
				)
			),
		),
	);
	$return['apps']=pdo_getall('core_account_wxapp',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['htmls']=$htmls;
	exi($return);
}
